#include<iostream>
#include<cstring>
#include<queue>
using namespace std;
int M,N,T;
struct Dir{
    int r,c;
}dir[4]={{1,0},{-1,0},{0,1},{0,-1}};
struct Pos{
    int r,c,ck,steps;
    Pos(){};
    Pos(int rr,int cc,int ssteps,int cck):r(rr),c(cc),ck(cck),steps(ssteps){};
};
int used[205][205][15];
char a[205][205];
Pos s,e;
queue<Pos> q;
int main(){
    cin>>M>>N>>T;
    memset(used,0xff,sizeof(used));
    for(int i=1;i<=M;i++)
    for(int j=1;j<=N;j++){
        cin>>a[i][j];
        if(a[i][j]=='@'){
            s=Pos(i,j,0,T);
        }else if(a[i][j]=='+'){
            e=Pos(i,j,-1,-1);
            a[i][j]='*';
        }
        for(int t=0;t<=T;t++){
            used[i][j][t]=0;
        }
    }
    used[s.r][s.c][T]=1;
    q.push(s);
    while(!q.empty()){
        Pos p=q.front();
        if(p.r==e.r&&p.c==e.c){
            cout<<p.steps<<endl;
            return 0;
        }
        q.pop();

        int nr,nc;
        for(int i=0;i<4;i++){
            nr=p.r+dir[i].r;
            nc=p.c+dir[i].c;
            if(a[nr][nc]=='*'&&!used[nr][nc][p.ck]){
                used[nr][nc][p.ck]=1;
                q.push(Pos(nr,nc,p.steps+1,p.ck));
            }else if(a[nr][nc]=='#'&&!used[nr][nc][p.ck-1]){
                used[nr][nc][p.ck-1]=1;
                q.push(Pos(nr,nc,p.steps+1,p.ck-1));
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}